package com.ruoyi.web.controller.comlbs;


import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AlarmTypeCompany;
import com.ruoyi.system.service.IAlarmTypeCompanyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 告警类型与公司中间Controller
 * 
 * @author wp
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/comlbs/alarmTypeCompany")
public class AlarmTypeCompanyController extends BaseController {
    @Autowired
    private IAlarmTypeCompanyService alarmTypeCompanyService;

    /**
     * 查询告警类型与公司中间列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AlarmTypeCompany alarmTypeCompany) {
        startPage();
        List<AlarmTypeCompany> list = alarmTypeCompanyService.selectList(alarmTypeCompany);
        return getDataTable(list);
    }

    /**
     * 导出告警类型与公司中间列表
     */
    @Log(title = "告警类型与公司中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlarmTypeCompany alarmTypeCompany) {
        List<AlarmTypeCompany> list = alarmTypeCompanyService.selectList(alarmTypeCompany);
        ExcelUtil<AlarmTypeCompany> util = new ExcelUtil<AlarmTypeCompany>(AlarmTypeCompany.class);
        util.exportExcel(response, list, "告警类型与公司中间数据");
    }

    /**
     * 获取告警类型与公司中间详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(alarmTypeCompanyService.getById(id));
    }

    /**
     * 新增告警类型与公司中间
     */
    @Log(title = "告警类型与公司中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlarmTypeCompany alarmTypeCompany) {
        return toAjax(alarmTypeCompanyService.save(alarmTypeCompany));
    }

    /**
     * 修改告警类型与公司中间
     */
    @Log(title = "告警类型与公司中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlarmTypeCompany alarmTypeCompany)
    {
        return toAjax(alarmTypeCompanyService.updateById(alarmTypeCompany));
    }

    /**
     * 删除告警类型与公司中间
     */
    @Log(title = "告警类型与公司中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(alarmTypeCompanyService.removeByIds(Arrays.asList(ids)));
    }
}
